package com.heimali.happyreader.utils;

import com.heimali.happyreader.HappyReaderApplication;
import com.heimali.happyreader.R;
import com.heimali.happyreader.config.Constants;

public class ErrorUtils {
	public static int[] errnos = {UserUtils.USERNAME_HAD_USED, UserUtils.USERNAME_NOT_EMAIL, UserUtils.PASSWORD_TOO_LONG, UserUtils.PASSWORD_TOO_SHORT, UserUtils.USERNAME_OR_PASSWORD_ERROR, Constants.E_UNKNOWN_ERROR, Constants.E_NETWORK_NOT_AVAILABLE, Constants.E_SERVER_BUSY};
	public static int[] errmsgs = {R.string.username_had_used, R.string.username_not_email, R.string.password_length_limit, R.string.password_length_limit, R.string.username_or_password_error, R.string.unknown_error, R.string.network_not_available, R.string.server_busy};
	
	public static String getMsg(int errno) {
		int idx=0, len=errnos.length;
		for( ; idx<len ; idx++) {
			if (errnos[idx] == errno) {
				break;
			}
		}
		
		return HappyReaderApplication.getContext().getResources().getString(errmsgs[idx]);
	}
}
